from django.db import models

class goods(models.Model):
    goodsid = models.AutoField(primary_key=True)
    goodsname = models.CharField(max_length=50)
    goodsimg = models.CharField(max_length=40)
    goodsdetail = models.CharField(max_length=40)
    goodsprice = models.CharField(max_length=20)


class user(models.Model):
    userid = models.AutoField(primary_key=True)
    username = models.CharField(max_length=10)
    userphone = models.CharField(max_length=20)
    userpassword = models.CharField(max_length=30)
    #联合主键
    class Meta:
        unique_together = ("userid", "username", "userphone")


class address(models.Model):
    id = models.AutoField(primary_key=True)
    userid = models.ForeignKey(user, on_delete=models.CASCADE)
    receive_name = models.CharField(max_length=10)
    receive_address = models.CharField(max_length=50)
    detailed_address = models.CharField(max_length=50)
    phone = models.CharField(max_length=20)




class shoppingcar(models.Model):
    id = models.AutoField(primary_key=True)
    goodsid = models.CharField(max_length=5)
    userid = models.CharField(max_length=5)
    size = models.CharField(max_length=5)
    count = models.CharField(max_length=10)


class order(models.Model):
    id = models.AutoField(primary_key=True)
    userid = models.ForeignKey(user, on_delete=models.CASCADE)
    goodsid = models.ForeignKey(goods, on_delete=models.CASCADE)


class phonemsg(models.Model):
    id = models.AutoField(primary_key=True)
    msg = models.CharField(max_length=10)



